import React from 'react';
import { KfBizDataSelect, KfBizDataSelectProps, KfBizDataTableSelect, KfBizDataTableSelectProps } from 'kf-web-library';
import * as API from '@/services';
import classNames from 'classnames';
import { BizKfExtraProColumnType } from '@/components';

const HxJournalSpecialTopicSelect = (props: Partial<KfBizDataSelectProps<API.JournalSpecialTopic, API.JournalSpecialTopicPageQueryParams>>) => {
  return (
    <KfBizDataSelect<API.JournalSpecialTopic, API.JournalSpecialTopicPageQueryParams>
      request={(p) => API.queryJournalSpecialTopics({
        ...p ,
        pageSize: 1000,
      })}
      entityKeys={{
        primaryKey: 'id',
        labelKey: 'name',
      }}
      {...props}
      className={classNames('hx-journal-special-topic-select', props?.className)}
    />
  );
};

const HxJournalSpecialTopicTableSelect = (props: Partial<KfBizDataTableSelectProps<API.JournalSpecialTopic, API.JournalSpecialTopicPageQueryParams, BizKfExtraProColumnType>>) => {
  return (
    <KfBizDataTableSelect<API.JournalSpecialTopic, API.JournalSpecialTopicPageQueryParams, BizKfExtraProColumnType>
      entityTypeName={'特殊文章类型'}
      columns={[
        {
          title: '名称',
          dataIndex: 'name',
          sorter: false,
          hideInSearch: true,
          ellipsis: true,
        },
      ]}
      request={(p) => API.queryJournalSpecialTopics(p)}
      entityKeys={{
        primaryKey: 'id',
        labelKey: 'name',
      }}
      {...props}
      className={classNames('hx-journal-special-topic-table-select', props?.className)}
    />
  );
};

interface CompoundedComponent {
  Select: typeof HxJournalSpecialTopicSelect;
  TableSelect: typeof HxJournalSpecialTopicTableSelect;
}

const picker: CompoundedComponent = {
  Select: HxJournalSpecialTopicSelect,
  TableSelect: HxJournalSpecialTopicTableSelect,
};

export default picker;
